<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增阀门型号数据')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-type-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">阀门型号：</label>
                <div class="col-sm-8">
                    <input name="typeName" id="typeName"  class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">阀门类型：</label>
                <div class="col-sm-8">
                    <select name="typeModel" class="form-control m-b" th:with="type=${@dict.getType('valve_model')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">通信协议：</label>
                <div class="col-sm-8">
                    <select name="typeAgree" class="form-control m-b" th:with="type=${@dict.getType('valve_agree')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">设备厂商：</label>
                <div class="col-sm-8">
                    <select id="factoryId" name="factoryId" class="form-control">
                        <option th:each="factory:${factorys}" th:value="${factory.factoryId}" th:text="${factory.factoryName}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "module/valve"
        $("#form-type-add").validate({
            onkeyup: false,
            rules: {
                typeName: {
                    remote: {
                        url: prefix + "/checkValveTypeCodeUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "typeName": function() {
                                return $.common.trim($("#typeName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "typeName": {
                    remote: "阀门型号已存在"
                }
            },

            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-type-add').serialize());
            }
        }
    </script>
</body>
</html>